home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16034 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  60 lines

  1. Path: siemens.at!usenet
  2. From: "Helge Sⁿ▀" <helge@siemens.co.at>
  3. Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.lang.c++,comp.lang.basic.visual.database,comp.lang.basic.visual
  4. Subject: Re: HELP !!! WIth VB & DLL connection
  5. Date: 9 Apr 1996 09:13:57 GMT
  6. Organization: Siemens AG Austria
  7. Message-ID: <4kd9ol$o15@news.siemens.at>
  8. References: <NEWTNews.31178.827960329.Postmaster@Jerusalem.netvision.net.il>
  9. NNTP-Posting-Host: pc5888.hil.siemens-austria
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  14.  
  15. iti@Jerusalem.netvision.net.il wrote:
  16. >
  17. >I have a DLL written in Visual C++ and am trying to write a Visual Basic (Ver. >3) application to use it.  I am new to VB so I have two questions.
  18. >
  19. >    1.  How can I access the message que (in order to do my own message >processing) in a VB application?
  20. >
  21. >    2.  I have a C DLL function declaired as 
  22. >"char far*   WINAPI    _export    MyFunct(void)  ".  How do I declare it in VB.
  23. >
  24.  
  25. Declare Function MyFunct Lib "MyDll.DLL" As Long
  26.  
  27. You won't be happy with the char* though because VB Strings are handled
  28. in a VERY different way. If you want to return a string result pass a
  29. pointer to the function and a pre-initialized string at runtime.
  30.  
  31. e.g. int WINAPI _export MyFunct(char* result);
  32.  
  33. Declare Function MyFunct Lib "MyDll.DLL" (ByVal result As String) As Integer
  34.  
  35. (if you want to return a negative error code as function result in the int
  36. or the length of the string if successful)
  37.  
  38. Then call it like this:
  39.  
  40. Dim ok As Integer
  41. Dim resultstring As String
  42.  
  43. resultstring = "lotsofspacesuptothemaxyou'llexpect" & chr$(0)
  44. ok = MyFunct(resultstring)
  45. If ok >= 0 Then
  46.     resultstring = Left$(resultstring, ok)
  47. Else
  48.    ' got some error to report
  49. End If
  50.  
  51. Helge ;-)=)
  52.  
  53. ----------------------------------------------------------
  54.       (c) All Thoughts are Mine -- Genuine Genius
  55. ----------------------------------------------------------
  56. helge@siemens.co.at        -----         VIENNA -- AUSTRIA
  57. ----------------------------------------------------------
  58.  
  59.  
  60.